import {createRouter, createWebHistory, RouteRecordRaw} from 'vue-router'
import type {Router} from  "vue-router"
import type {RouterOptions} from 'vue-router'
import Layout from "@/components/Layout/index.vue"
import Home from  "../views/home/Home.vue"
import QuestionList from  "../views/questionList/QuestionList.vue"
import JudgeList from  "../views/judge/judgeList.vue"
import Rankings from  "../views/rankings/Rankings.vue"
import Problem from "@/views/problem/Problem.vue"
import ProblemList from "@/views/problem/ProblemList.vue"
const staticRoutes  = [
  {
    path:"/articles/:userId?",
    name:"Articles",
    component:() => import("@/views/blog/index")
  },
  {
    path:'/contestIn',
    name:'ContestIn',
    component: () => import('@/views/contest/in/index'),
    children:[
      {
        path:"problemList/:contestId",
        name:"ContestInProblemList",
        component: () => import("@/views/contest/in/ContestProblemList")
      },
      {
        path:"problem/:contestId/:problemId",
        name:"ContestInProblem",
        component: () => import("@/views/contest/in/ContestProblem")
      },
      {
        path:"submitList/:contestId",
        name:"SubmitList",
        component: () => import("@/views/judge/judgeList")
      },
      {
        path:"OIRanking/:contestId",
        name:"OIRanking",
        component: () => import("@/views/contest/in/OIRanking.vue")
      },
      {
        path:"ACMRanking/:contestId",
        name:"ACMRanking",
        component: () => import("@/views/contest/in/ACMRanking")
      },
    ]
  },
  {
    path: '/',
    name: 'layout',
    component:Layout,
    children:[
      {
        path:'',
        name: 'home',
        component:Home
      },
      {
        path:'notice',
        name: 'Notice',
        component:() => import("@/views/notice/index")
      },
      {
        path:'noticeDetails/:id',
        name: 'NoticeDetails',
        component:() => import("@/views/notice/details/index")
      },
      {
        path:'questionList',
        name: 'QuestionList',
        component:QuestionList
      },
      {
        path:"problemListDetail/:id?",
        name:"ProblemListDetail",
        component:() => import("@/views/questionList/Question")
      },
      {
        path:'judgeList',
        name: 'JudgeList',
        component:JudgeList,
        meta: {
          keepAlive: true // true 表示需要使用缓存
        },
      },
      {
        path:"judge/:id?",
        name:"Judge",
        component: () => import("@/views/judge/judge")
      },
      {
        path:"rankings",
        name: 'Rankings',
        component:Rankings,
      },
      {
        path:"contestList",
        name: 'ContestList',
        component:() => import("@/views/contest/ContestList")
      },
      {
        path:"contest/:contestId",
        name: 'Contest',
        component:() => import("@/views/contest/Contest")
      },
      {
        path:"discuss/:userId?",
        name:"Discuss",
        component:() => import("@/views/blog/index"),
        meta: {
          keepAlive: true // true 表示需要使用缓存
        },
      },
      {
        path:"article/:id",
        name:"Article",
        component:() => import("@/views/blog/details/index")
      },
      {
        path:"user/:userId?",
        name:"User",
        component:() => import("@/views/user/User")
      },
      {
        path:"problem/:problemId?",
        name:"Problem",
        component:Problem
      },
      {
        path:"problemList",
        name:"ProblemList",
        meta: {
          keepAlive: true // true 表示需要使用缓存
        },
        component:ProblemList
      },
      {
        path:"problemList2/:contestId",
        name:"ContestInProblemList2",
        component: () => import("@/views/contest/in/ContestProblemList")
      },

    ]
  },
  {
    path:"/addArticle",
    name:"AddArticle",
    component:() => import("@/views/blog/AddArticle")
  },
  {
    path: '/codemirror',
    name: 'Codemirror',
    component: () => import("@/views/codemirror"),
  },
] as RouteRecordRaw[]
const router  = createRouter(<RouterOptions>{
  history: createWebHistory(),
  routes: staticRoutes
}) as Router;
export default router
